<template>
    <div style="height:100%;width:100%;position:relative;" ref="maindev">
        <div class="pagetop" :style="pagetopstyle">
            <div style="width:100%;">
                <el-col>
                    <div ref="buttondiv">
                        <!-- <vxe-toolbar>
                            <template v-slot:buttons> -->
                        <table style="width: 100%; font-size: 12px;" border="0">
                            <col style="width: 4%;" />
                            <col style="width: 7%;" />
                            <col style="width: 1%;" />
                            <col style="width: 7%;" />
                            <col style="width: 4%;" />
                            <col style="width: 10%;" />
                            <col style="width: 4%;" />
                            <col style="width: 10%;" />
                            <col style="width: 4%;" />
                            <col style="width: 10%;" />
                            <col style="width: 4%;" />
                            <col style="width: 35%;" />
                            <tr>
                                <td>
                                    <el-dropdown @command="handleCommand" style="font-size: 12px;">
                                        <u class="el-dropdown-link">
                                            {{ datename }}
                                        </u>
                                        <el-dropdown-menu slot="dropdown">
                                            <el-dropdown-item command="标本日期">
                                                <font font-size="12px">标本日期</font>
                                            </el-dropdown-item>
                                            <el-dropdown-item command="审核日期">
                                                <font font-size="12px">审核日期</font>
                                            </el-dropdown-item>
                                        </el-dropdown-menu>
                                    </el-dropdown>
                                </td>
                                <!-- <td>
                                    <el-date-picker v-model="sel_date" type="daterange" start-placeholder="开始日期" range-separator="至" end-placeholder="结束日期" value-format="yyyy-MM-dd" style="width:240px;">
                                    </el-date-picker>
                                </td> -->
                                <td>
                                    <el-date-picker v-model="sample_startdt" :able="false" type="date" placeholder="选择日期"
                                        value-format="yyyy-MM-dd" style="width:100%;min-width: 100px;" :clearable="false">
                                    </el-date-picker>
                                </td>
                                <td align="center">至</td>
                                <td>
                                    <el-date-picker v-model="sample_enddt" type="date" :able="false" placeholder="选择日期"
                                        value-format="yyyy-MM-dd" style="width:100%;min-width: 100px;" :clearable="false">
                                    </el-date-picker>
                                </td>
                                <td>报告单元</td>
                                <td>
                                    <rm-ddl-rptunit prgno="LIS411" defaultflag="1" v-model="sel_rptunit" width="100%"
                                        @change="rptunitChange"></rm-ddl-rptunit>
                                </td>
                                <td>姓名</td>
                                <td>
                                    <el-input size="small" style="width:calc( 100% - 60px );"
                                        v-model="sel_patname"></el-input>&nbsp;
                                    <el-checkbox v-model="sel_patname_mh" style="width:60px">模糊</el-checkbox>
                                </td>
                                <td>申请科室</td>
                                <td>
                                    <rm-ddl-common datatype="dept" dataname="科室" v-model="sel_reqdeptno"
                                        style="width:100%;min-width: 100px;" @change="reqdeptChange"></rm-ddl-common>
                                </td>
                                <td>所属院区</td>
                                <td>
                                    <rm-ddl-common datatype="hospital" dataname="医院" v-model="sel_hospcode"
                                        style="width:100%;min-width: 100px;" @change="hospChange"></rm-ddl-common>
                                </td>

                            </tr>
                            <tr>
                                <td>标本类型</td>
                                <td colspan="3">
                                    <rm-ddl-common ref="ddlspecimen" datatype="specimen" dataname="标本类型"
                                        v-model="sel_specimencode" width="100%" @change="specimenChange"></rm-ddl-common>
                                </td>
                                <td>病历号</td>
                                <td>
                                    <el-input size="small" style="width:100%;min-width:130px"
                                        v-model="sel_patno"></el-input>
                                </td>
                                <td>病人ID</td>
                                <td>
                                    <el-input size="small" style="width:100%;min-width:150px"
                                        v-model="sel_patid"></el-input>
                                </td>
                                <td>病人来源</td>
                                <td>
                                    <el-select v-model="sel_pattypecode" placeholder="请选择" style="width:100%"
                                        min-width="150px">
                                        <el-option key="0" label="全部" value="0"></el-option>
                                        <el-option key="1" label="门诊" value="1"></el-option>
                                        <el-option key="2" label="急诊" value="2"></el-option>
                                        <el-option key="3" label="住院" value="3"></el-option>
                                        <el-option key="4" label="体检" value="4"></el-option>
                                    </el-select>
                                </td>
                                <td>病区</td>
                                <td>
                                    <rm-ddl-common :appendtobody="true" datatype="ward" dataname="病区"
                                        v-model="sel_reqwardno" @change="reqwardChange"></rm-ddl-common>
                                </td>
                            </tr>
                            <tr>
                                <td>标本号</td>
                                <td colspan="3">
                                    <el-input size="small" style="width:100%;" placeholder="输入如1,2,5-8等格式"
                                        v-model="sel_sampleno"></el-input>
                                </td>
                                <td>急诊标志</td>
                                <td>
                                    <el-select v-model="sel_emerflag" placeholder="请选择" style="width:100%">
                                        <el-option key="all" label="全部" value="all"></el-option>
                                        <el-option key="0" label="常规" value="0"></el-option>
                                        <el-option key="1" label="加急" value="1"></el-option>
                                    </el-select>
                                </td>
                                <td>条码号</td>
                                <td>
                                    <el-input size="small" style="width:100%;min-width:150px"
                                        v-model="sel_barcode"></el-input>
                                </td>
                                <td>床号</td>
                                <td>
                                    <el-input size="small" style="width:100%;min-width: 150px;"
                                        v-model="sel_reqbedno"></el-input>
                                </td>
                            </tr>
                            <tr v-show="show_sel">
                                <td>报告项目</td>
                                <td colspan="3">
                                    <rm-ddl-rptitem prgno="LIS411" isAllRpt="1" v-model="sel_rptitemcode" width="100%"
                                        :appendtobody="true" @change="rptitemChange"></rm-ddl-rptitem>
                                </td>

                                <td>申请医生</td>
                                <td>
                                    <rm-ddl-common datatype="userinfo" dataname="用户" v-model="sel_reqdocno" width="100%"
                                        @change="reqdocChange"></rm-ddl-common>
                                </td>
                                <td>结果标志</td>
                                <td>
                                    <el-select v-model="sel_rflag" placeholder="请选择" style="width:100%">
                                        <el-option key="all" label="全部" value="all"></el-option>
                                        <el-option key="0" label="异常" value="0"></el-option>
                                        <el-option key="1" label="正常" value="1"></el-option>
                                    </el-select>
                                </td>
                                <td>临床诊断</td>
                                <td>
                                    <el-input size="small" style="width:100%;" v-model="sel_patdiag"></el-input>
                                </td>
                                <td></td>
                            </tr>
                            <tr v-show="show_sel">
                                <td>报告单元多选</td>
                                <td colspan="3">
                                    <rm-ddl-rptunit prgno="LIS411" :multiple_choice="true" v-model="sel_rptunitlist"
                                        width="100%" @change="rptunitsChange"></rm-ddl-rptunit>
                                </td>
                                <td>审核状态</td>
                                <td>
                                    <el-select v-model="sel_rechkflag" style="width:100%">
                                        <el-option label="全部" value='A'>全部</el-option>
                                        <el-option label="未审核" value='0'>未审核</el-option>
                                        <el-option label="已审核" value='9'>已审核</el-option>
                                    </el-select>
                                </td>
                                <td></td>
                                <td>
                                    <el-checkbox true-label="1" false-label="0"
                                        v-model="sel_od_cutoff">显示OD、SCO、Cutoff值</el-checkbox>
                                </td>
                                <td></td>
                            </tr>
                            <tr>
                                <td colspan="12" align="right">
                                    <el-link :underline="false" @click="btn_openselEvent">
                                        {{ show_sel ? '收起▲' : '展开▼' }}
                                    </el-link>
                                    <el-button icon="el-icon-search" v-has="'PINQUERY'" type="primary" style="align:left"
                                        @click="btnQuery">查询</el-button>
                                    <el-button icon="el-icon-delete" v-has="'PPRINT'" @click="btnClear">清除</el-button>
                                    <el-button icon="el-icon-printer" @click="btnPrint(1)">打印</el-button>
                                    <!-- <el-button icon="el-icon-zoom-in" @click="btnPrint(2)">预览</el-button> -->
                                    <el-button icon="el-icon-printer" @click="btnPrint(3)"
                                        v-if="this.$tool.getSession(this.$tool.loginutype) == 'G'">设计</el-button>
                                    <el-button icon="el-icon-upload2" v-has="'PEXPORT'"
                                        @click="btnExportRpt(1)">导出报告</el-button>
                                    <el-button icon="el-icon-upload2" v-has="'PEXPORT'"
                                        @click="btnExportRpt(2)">导出结果</el-button>
                                </td>
                            </tr>
                        </table>
                        <!-- </template>
                        </vxe-toolbar> -->
                    </div>
                </el-col>
            </div>
        </div>
        <div :style="pagecenter">
            <div :style="middle_center">
                <vxe-table :data.sync="report_date" :loading="report_Loading" :select-config="{ reserve: true }"
                    :sort-config="{ trigger: 'cell' }" border :height="reportheight" highlight-current-row
                    highlight-hover-column highlight-hover-row how-header-overflow ref="reporttable" resizable show-overflow
                    size="mini" :row-class-name="reportRowName" show-header-overflow :optimization="{ animat: false }"
                    @current-change="reportchange_Event" :cell-class-name="reportCellName" @cell-click="cellClickEvent"
                    header-align="center">
                    <vxe-table-column field="alter_flag" sortable title="危" width="20" show-overflow align="center">
                        <template v-slot="{ row, rowIndex, columnIndex }">
                            <div :key="row.userno + rowIndex + columnIndex"
                                v-if="row.alter_flag == '1' || row.alter_flag == '2'">
                                <font color="#000000">危</font>
                            </div>
                            <div :key="row.userno + rowIndex + columnIndex" v-else>
                            </div>
                        </template>
                    </vxe-table-column>
                    <vxe-table-column field="emer_flag" sortable title="急" width="20" show-overflow align="center">
                        <template v-slot="{ row, rowIndex, columnIndex }">
                            <div :key="row.userno + rowIndex + columnIndex" v-if="row.emer_flag == '1'">
                                <font color="red">急</font>
                            </div>
                            <div :key="row.userno + rowIndex + columnIndex" v-else>
                            </div>
                        </template>
                    </vxe-table-column>
                    <vxe-table-column field="redo_flag" sortable title="复" width="20" show-overflow align="center">
                        <template v-slot="{ row, rowIndex, columnIndex }">
                            <div :key="row.userno + rowIndex + columnIndex"
                                v-if="row.redo_flag == '2' || row.redo_flag == '3'">
                                <font color="#000000">复</font>
                            </div>
                            <div :key="row.userno + rowIndex + columnIndex" v-else>
                            </div>
                        </template>
                    </vxe-table-column>
                    <vxe-table-column field="rechkflag" sortable title="审" width="20" show-overflow align="center">
                        <template v-slot="{ row, rowIndex, columnIndex }">
                            <div :key="row.userno + rowIndex + columnIndex" v-if="row.rechkflag == '9'">
                                <font color="#000000">审</font>
                            </div>
                            <div :key="row.userno + rowIndex + columnIndex" v-else>
                            </div>
                        </template>
                    </vxe-table-column>
                    <vxe-table-column field="rptunitname" sortable title="报告单元" width="150"
                        show-overflow></vxe-table-column>
                    <vxe-table-column align="center" field="sampledate" sortable title="标本日期" width="70"
                        :formatter="['toDateString', 'yyyy-MM-dd']" show-overflow></vxe-table-column>
                    <vxe-table-column field="sampleno" align="center" sortable title="标本编号" width="80" show-overflow
                        :sort-width="20"></vxe-table-column>
                    <vxe-table-column field="pat_name" align="center" sortable title="病人姓名" width="80"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="pat_no" sortable title="病人号" width="150" show-overflow></vxe-table-column>
                    <vxe-table-column field="pat_sexname" align="center" sortable title="性别" width="35"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="pat_nationna" align="center" sortable title="民族" width="80"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="rechk_dt" align="center" sortable title="审核时间" width="120"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="rechk_user" align="center" sortable title="审核医生" width="60"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="pat_id" sortable title="病人ID" width="130" show-overflow></vxe-table-column>
                    <vxe-table-column field="release_dt" align="center" sortable title="发布时间" width="140"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="release_user" align="center" sortable title="发布人" width="70"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="print_count" align="center" sortable title="打印次数" width="60"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="req_reason" sortable title="送检目的" width="400" show-overflow></vxe-table-column>
                    <vxe-table-column field="pat_agestr" align="center" sortable title="年龄" width="40"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="specimen" sortable title="标本类型" width="90" show-overflow></vxe-table-column>
                    <vxe-table-column field="req_bedno" align="center" sortable title="床号" width="50"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="pat_typecodename" align="center" sortable title="病人类别" width="80"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="barcode" sortable title="条码号" width="100" show-overflow></vxe-table-column>
                    <vxe-table-column field="req_dept" sortable title="申请科室" width="130" show-overflow></vxe-table-column>
                    <vxe-table-column field="req_wardno" sortable title="病人病区" width="100" show-overflow></vxe-table-column>
                    <vxe-table-column field="charge_typeno" align="center" sortable title="收费类别" width="90"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="pat_diag" sortable title="临床诊断" width="250" show-overflow></vxe-table-column>
                    <vxe-table-column field="req_dt" align="center" sortable title="申请时间" width="140"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="req_doc" align="center" sortable title="申请医生" width="70"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="pat_cardno" sortable title="就诊卡号" width="110" show-overflow></vxe-table-column>
                    <vxe-table-column field="inp_id" sortable title="就诊号" width="100" show-overflow></vxe-table-column>
                    <vxe-table-column field="sampled_dt" align="center" sortable title="采样时间" width="140"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="recieve_dt" align="center" sortable title="接收时间" width="140"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="input_dt" align="center" sortable title="录入时间" width="140"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="test_info" sortable title="上机信息" width="120" show-overflow></vxe-table-column>
                    <vxe-table-column field="test_dt" align="center" sortable title="上机时间" width="140"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="report_dt" align="center" sortable title="报告时间" width="140"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="report_username" align="center" sortable title="检验医生" width="70"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="report_comm" sortable title="报告单备注" width="150"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="lab_advice" sortable title="实验室意见" width="100"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="item_num" align="center" sortable title="项目数" width="50"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="instr_advice" sortable title="仪器辅助诊断" width="150"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="rechk2_dt" align="center" sortable title="二审时间" width="140"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="rechk2_user" align="center" sortable title="二审医生" width="70"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="lastprint_dt" align="center" sortable title="最后打印时间" width="140"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="pat_birth" align="center" sortable title="病人生日" width="90"
                        :formatter="['toDateString', 'yyyy-MM-dd']" show-overflow></vxe-table-column>
                    <vxe-table-column field="prereport_dt" align="center" sortable title="预计报告时间" width="140"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="reportid" sortable title="报告ID" width="160" show-overflow></vxe-table-column>
                    <vxe-table-column field="HospCode" sortable title="送检医院" width="180" show-overflow></vxe-table-column>
                    <vxe-table-column field="inp_date" align="center" sortable title="入院日期" width="140"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="pat_phone" sortable title="联系电话" width="100" show-overflow></vxe-table-column>
                    <vxe-table-column field="is_changed" align="center" sortable title="是否修改" width="70"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="changed_afterreport" align="center" sortable title="打印、审核后修改" width="130"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="unprint_flag" align="center" sortable title="禁止打印标志" width="100"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="unprint_reason" sortable title="禁止打印原因" width="150"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="pat_diag_icd" sortable title="临床诊断标准码" width="160"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="pat_address" sortable title="病人地址" width="200"
                        show-overflow></vxe-table-column>
                    <vxe-table-column field="pat_idcardno" align="center" sortable title="身份证/护照号" width="200"
                        show-overflow></vxe-table-column>
                </vxe-table>
                <div class="fixtotal">
                        <div style="font-size:12px;padding-top:3px;background-color:#fff;"><span
                                style="color:red;margin-left:10px;float:right;">合计: {{ rpt_amount }}</span>
                            <div style="clear:both"></div>
                        </div>
                    </div>
            </div>
            <div class="middle-right" v-show="show_right">
                <div v-if="is_ym" class="right-inser">
                    <div class="middle-tab-top">
                        <vxe-table :data.sync="result_data" :loading="result_Loading" :select-config="{ reserve: true }"
                            :sort-config="{ trigger: 'cell' }" border height="auto" highlight-current-row
                            header-align="center" highlight-hover-column highlight-hover-row how-header-overflow
                            ref="ymresulttable" resizable show-overflow size="mini" stripe show-header-overflow
                            :optimization="{ animat: false }">
                            <vxe-table-column field="rpt_itemname" sortable title="检验项目" width="220"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="result_str" sortable title="检测结果" width="80"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="result1" sortable title="菌落计数" width="150"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="result4" sortable title="耐药机制" width="100"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="instrid" sortable title="检验仪器" width="100"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="interno" sortable title="通道号" width="100"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="alertflag" align="center" sortable title="危急标志" width="60"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="result_flag" align="center" sortable title="结果标志" width="60"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="redo_flag" align="center" sortable title="复查标志" width="60"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="redo_result" sortable title="复查前结果" width="80"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="orig_result_num" sortable title="原始数值结果" width="150"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="orig_result_str" sortable title="原始文本结果" width="150"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="modify_flag" sortable title="修改标志" width="100"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="first_dt" align="center" sortable title="第一次填入时间" width="120"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="last_dt" align="center" sortable title="最后修改时间" width="120"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="last_user" align="center" sortable title="最后修改人" width="80"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="rptunitid" sortable title="报告单元" width="100"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="germflag" align="center" sortable title="细菌标志" width="60"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="orig_result_flag" align="center" sortable title="原始结果标志" width="60"
                                show-overflow></vxe-table-column>
                        </vxe-table>
                        <div class="fixtotal2">
                            <div style="font-size:12px;padding-top:3px;background-color:#fff;"><span
                                        style="color:red;margin-left:10px;float:right;">合计: {{ result_amount }}</span>
                                    <div style="clear:both"></div>
                                </div>
                        </div>
                    </div>
                    <div class="middle-tab-bottom">
                        <vxe-table :data.sync="resusltmed_date" :select-config="{ reserve: true }"
                            :sort-config="{ trigger: 'cell' }" border :height="ymresultheight" highlight-current-row
                            highlight-hover-column highlight-hover-row how-header-overflow ref="ymresulttable" resizable
                            show-overflow size="mini" stripe show-header-overflow :optimization="{ animat: false }"
                            header-align="center">
                            <vxe-table-column field="medname" sortable title="抗生素" width="220"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="medresult" sortable title="药敏结果" width="100"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="Rad" sortable title="Rad" width="60" show-overflow></vxe-table-column>
                            <vxe-table-column field="Mic" sortable title="Mic" width="60" show-overflow></vxe-table-column>
                            <vxe-table-column field="result_flag" sortable title="标志" width="60"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="result6" sortable title="参考范围" width="100"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="expertresult" sortable title="专家值" width="100"
                                show-overflow></vxe-table-column>
                            <vxe-table-column field="medgroup" sortable title="分组" width="100"
                                show-overflow></vxe-table-column>
                        </vxe-table>
                        <div class="fixtotal">
                            <div style="font-size:12px;padding-top:3px;background-color:#fff;"><span
                                        style="color:red;margin-left:10px;float:right;">合计:
                                        {{ ymresultitem_amount }}</span>
                                    <div style="clear:both"></div>
                                </div>
                            </div>
                    </div>
                </div>
                <div v-if="!is_ym" class="right-inser">
                    <vxe-table :data.sync="result_data" :loading="result_Loading" :select-config="{ reserve: true }"
                        :sort-config="{ trigger: 'cell' }" border :height="resultheight" highlight-current-row
                        highlight-hover-column highlight-hover-row how-header-overflow ref="resulttable" resizable
                        show-overflow size="mini" stripe show-header-overflow :optimization="{ animat: false }"
                        header-align="center">
                        <vxe-table-column field="rpt_itemname" sortable title="检验项目" width="220" show-overflow> <template
                                v-slot="{ row }">
                                <div v-if="row.alertflag == '1'" style="background:red;padding:0px 10px">
                                    {{ row.rpt_itemname }}
                                </div>
                                <div v-else style="padding:0px 10px">
                                    {{ row.rpt_itemname }}
                                </div>
                            </template></vxe-table-column>
                        <vxe-table-column field="result_str" sortable title="检测结果" width="80" show-overflow> <template
                                v-slot="{ row }">
                                <div :style="{
                                    background: row.cp_resultbackgroundcolor,
                                    color: row.cp_resultcolor
                                }" style="padding:0px 10px">
                                    {{ row.result_str }}
                                </div>
                            </template></vxe-table-column>
                        <vxe-table-column field="result_unit" sortable title="单位" width="70"
                            show-overflow></vxe-table-column>
                        <vxe-table-column field="result_ref" sortable title="参考值" width="100"
                            show-overflow></vxe-table-column>
                        <vxe-table-column field="result1" :title="result1title" width="70px"
                            v-if="sel_od_cutoff == '1'"></vxe-table-column>
                        <vxe-table-column field="result2" :title="result2title" width="70px"
                            v-if="sel_od_cutoff == '1'"></vxe-table-column>
                        <vxe-table-column field="result3" :title="result3title" width="70px"
                            v-if="sel_od_cutoff == '1'"></vxe-table-column>
                        <vxe-table-column field="result_txt" sortable title="大文本结果" width="130"
                            show-overflow></vxe-table-column>
                        <vxe-table-column field="instrid" sortable title="检验仪器" width="100"
                            show-overflow></vxe-table-column>
                        <vxe-table-column field="interno" sortable title="通道号" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="alertflag" align="center" sortable title="危急标志" width="60"
                            show-overflow></vxe-table-column>
                        <vxe-table-column field="result_flag" align="center" sortable title="结果标志" width="60"
                            show-overflow></vxe-table-column>
                        <vxe-table-column field="redo_flag" align="center" sortable title="复查标志" width="60"
                            show-overflow></vxe-table-column>
                        <vxe-table-column field="redo_result" sortable title="复查前结果" width="120"
                            show-overflow></vxe-table-column>
                        <vxe-table-column field="orig_result_num" sortable title="原始数值结果" width="120"
                            show-overflow></vxe-table-column>
                        <vxe-table-column field="orig_result_str" sortable title="原始文本结果" width="120"
                            show-overflow></vxe-table-column>
                        <vxe-table-column field="modify_flag" align="center" sortable title="修改标志" width="60"
                            show-overflow></vxe-table-column>
                        <vxe-table-column field="first_dt" align="center" ortable title="第一次填入时间" width="120"
                            show-overflow></vxe-table-column>
                        <vxe-table-column field="last_dt" align="center" sortable title="最后修改时间" width="120"
                            show-overflow></vxe-table-column>
                        <vxe-table-column field="last_user" align="center" sortable title="最后修改人" width="80"
                            show-overflow></vxe-table-column>
                        <vxe-table-column field="rptunitid" sortable title="报告单元" width="150"
                            show-overflow></vxe-table-column>
                        <vxe-table-column field="germflag" align="center" sortable title="细菌标志" width="60"
                            show-overflow></vxe-table-column>
                        <vxe-table-column field="orig_result_flag" align="center" sortable title="原始结果标志" width="160"
                            show-overflow></vxe-table-column>
                    </vxe-table>
                    <div class="fixtotal">
                        <div style="font-size:12px;padding-top:3px;background-color:#fff;"><span
                                    style="color:red;margin-left:10px;float:right;">合计: {{ result_amount }}</span>
                                <div style="clear:both"></div>
                            </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { Promise } from "q";
import { invalid } from "moment";
import XE from "xe-utils"; //引入工具类
export default {
    name: "LIS411",
    data() {
        return {
            pagetopstyle: {
                height: "135px",
            },
            pagecenter: {
                position: "absolute",
                top: "138px",
                bottom: "0px",
                overflow: "auto",
                width: "100%",
                left: "0px",
            },
            middle_center: {
                position: "absolute",
                height: "100%",
                right: "575px",
                left: "0px",
                overflow: "auto",
            },
            show_sel: false,
            report_Loading: false,
            report_date: [],
            sel_rptunit: "",
            sel_rptunitlist: "",
            sel_patno: "",
            sel_patid: "",
            sel_reqbedno: "",
            // sel_date: [XE.toDateString(XE.getWhatDay(new Date(), -30), "yyyy-MM-dd"), XE.toDateString(new Date(), "yyyy-MM-dd")],
            sample_startdt: XE.toDateString(XE.getWhatDay(new Date(), -30), "yyyy-MM-dd"),
            sample_enddt: XE.toDateString(new Date(), "yyyy-MM-dd"),
            sel_patname: "",
            sel_patname_mh: false,
            sel_pattypecode: "0",
            sel_specimencode: "",
            sel_sampleno: "",
            sel_emerflag: "all",
            sel_reqdeptno: "",
            sel_rflag: "all",
            sel_rptitemcode: "",
            sel_barcode: "",
            sel_reqdocno: "",
            sel_patdiag: "",
            sel_reqwardno: "",
            sel_hospcode: "",
            sel_od_cutoff: "0",
            sel_rechkflag: "A",
            show_right: true,
            is_ym: true, //是否显示药敏
            result_data: [],
            result_Loading: false,
            resusltmed_date: [],
            master_data: [],
            master_Loading: false,
            cellreportid: "",
            reportheight: "auto",
            resultheight: "auto",
            result1title: "",
            result2title: "",
            result3title: "",
            ymresultheight: "auto",
            buttonWidth: "",
            rpt_amount: 0,
            result_amount: 0,
            resusltmed_amount: 0,
            ymresultitem_amount: 0,
            styleid: "5034",
            operate: "",
            daytype: "1",
            datename: "标本日期",
            exportTableColLen: 0,
            rptunitname: "",
            reqdeptname: "",
            hospname: "",
            specimenname: "",
            reqwardname: "",
            rptitemname: "",
            reqdocname: "",
            rptunitsname: "",
            selrow: {},
        };
    },
    created() {
        this.btnClear();
        this.InitSecHospCode();
    },
    updated() {
        this.getButtonWidth();
    },
    methods: {
        InitSecHospCode() {
            this.loading = true;
            this.$tool
                .request({
                    url: "LIS/LIS4/LIS411",
                    method: "post",
                    data: {
                        action: "init_sechospcode",
                    },
                })
                .then((res) => {
                    if (res.secHospCode && res.secHospCode != "") {
                        this.sel_hospcode = res.secHospCode;
                    }
                });
        },
        btnQuery() {
            this.report_Loading = true;
            this.sqlWhere = "";
            this.$tool
                .request({
                    url: "LIS/LIS4/LIS411",
                    method: "post",
                    timeout: 600000,
                    data: {
                        action: "lab_report_query",
                        sample_startdt: this.sample_startdt,
                        sample_enddt: this.sample_enddt,
                        sel_rptunit: this.sel_rptunit,
                        sel_rptunitlist: this.sel_rptunitlist,
                        sel_patno: this.sel_patno,
                        sel_patid: this.sel_patid,
                        sel_reqbedno: this.sel_reqbedno,
                        sel_patname: this.sel_patname,
                        sel_patname_mh: this.sel_patname_mh ? "1" : "0",
                        sel_pattypecode: this.sel_pattypecode,
                        sel_specimencode: this.sel_specimencode,
                        sel_sampleno: this.sel_sampleno,
                        sel_emerflag: this.sel_emerflag,
                        sel_reqdeptno: this.sel_reqdeptno,
                        sel_hospcode: this.sel_hospcode,
                        sel_rflag: this.sel_rflag,
                        sel_rptitemcode: this.sel_rptitemcode,
                        sel_barcode: this.sel_barcode,
                        sel_reqdocno: this.sel_reqdocno,
                        sel_patdiag: this.sel_patdiag,
                        sel_reqwardno: this.sel_reqwardno,
                        sel_rechkflag: this.sel_rechkflag,
                        daytype: this.daytype, //标本日期(1) 审核日期(9)
                    },
                })
                .then((res) => {
                    this.report_date = res.RData.Data;
                    this.sqlWhere = res.wherebase64; // sqlwhere base64加密
                    this.result_data = [];
                    this.report_Loading = false;
                    if (res.RData.total > 5000) {
                        this.$message({
                            type: "info",
                            message: "超过5000行只显示前5000行数据！",
                        });
                    }
                    if (this.report_date.length > 0) {
                        this.fuc_get_labresult(this.report_date[0]);
                        this.cellreportid = this.report_date[0].reportid;
                    }
                    this.rpt_amount = res.RData.total;
                    this.show_sel = true;
                    this.btn_openselEvent();
                })
                .catch((e) => {
                    this.$message.error(e);
                });
        },
        reportchange_Event({ row, rowIndex, column, columnIndex }, event) {
            this.fuc_get_labresult(row);
        },
        fuc_get_labresult(row) {
            this.selrow = row;
            this.result_Loading = true;
            this.$tool
                .request({
                    url: "LIS/LIS4/LIS411",
                    method: "post",
                    data: {
                        action: "get_labresult",
                        reportid: row.reportid,
                        rptunitid: row.rptunitid,
                    },
                })
                .then((res) => {
                    if (res.rtn.length > 1) {
                        //药敏
                        this.is_ym = true;
                        this.result_data = res.rtn[0];
                        this.resusltmed_date = res.rtn[1];
                        this.result_amount = this.result_data.length;
                        this.ymresultitem_amount = this.resusltmed_date.length;
                    } else {
                        this.is_ym = false;
                        this.result_data = res.rtn[0];
                        this.result1title = res.result1title;
                        this.result2title = res.result2title;
                        this.result3title = res.result3title;
                        this.result_amount = this.result_data.length;
                    }
                    this.result_Loading = false;
                })
                .catch((e) => {
                    this.$message.error(e);
                });
        },
        handleCommand(name) {
            this.datename = name;
            if (name == "标本日期") this.daytype = "1";
            else if (name == "审核日期") this.daytype = "9";
        },
        btn_openselEvent() {
            let mainheight = this.$refs.maindev.offsetHeight;
            this.show_sel = !this.show_sel;
            // this.$nextTick(() => {
            if (this.show_sel) {
                // this.pagetopstyle.height = "170px";
                // this.pagecenter.top = "173px";
                this.pagetopstyle.height = "200px";
                this.pagecenter.top = "203px";
                this.reportheight = mainheight - 203;
                if (this.is_ym) {
                    this.ymresultheight = mainheight - 403;
                } else {
                    this.resultheight = mainheight - 203;
                }
            } else {
                this.pagetopstyle.height = "135px";
                this.pagecenter.top = "138px";
                this.reportheight = mainheight - 138;
                if (this.is_ym) {
                    this.ymresultheight = mainheight - 338;
                } else {
                    this.resultheight = mainheight - 138;
                }
            }
            // } else {
            //     this.pagetopstyle.height = "36px";
            //     this.pagecenter.top = "40px";
            //     this.reportheight = mainheight - 45;
            //     if (this.is_ym) {
            //         this.ymresultheight = mainheight - 247;
            //     } else {
            //         this.resultheight = mainheight - 45;
            //     }
            // }
            // });
        },
        btnClear() {
            this.show_sel = false;
            this.report_Loading = false;
            this.report_date = [];
            this.result_data = [];
            this.resusltmed_date = [];
            this.sel_rptunit = "";
            this.sel_rptunitlist = "";
            this.sel_patno = "";
            this.sel_patid = "";
            this.sel_reqbedno = "";
            this.sqlWhere = "";
            // this.sel_date = [XE.toDateString(XE.getWhatDay(new Date(), -30), "yyyy-MM-dd"), XE.toDateString(new Date(), "yyyy-MM-dd")];
            this.sample_startdt = XE.toDateString(XE.getWhatDay(new Date(), -30), XE.toDateString(new Date(), "yyyy-MM-dd"));
            this.sample_enddt = XE.toDateString(new Date(), "yyyy-MM-dd");
            this.sel_patname = "";
            this.sel_patname_mh = false;
            this.sel_pattypecode = "0";
            this.sel_specimencode = "";
            this.sel_sampleno = "";
            this.sel_emerflag = "all";
            this.sel_reqdeptno = "";
            this.sel_rflag = "all";
            this.sel_rptitemcode = "";
            this.sel_barcode = "";
            this.sel_reqdocno = "";
            this.sel_patdiag = "";
            this.sel_reqwardno = "";
            this.sel_hospcode = "";
            this.sel_od_cutoff = "0";
            this.sel_rechkflag = "A";
            this.show_right = true;
        },
        btnPrint(type) {
            if (this.report_date.length > 0) {
                if (type == 3) {
                    this.operate = "design";
                } else {
                    this.operate = "";
                }
                var sql = "Sp_Print_ReqSummrayList 'sqlwhere:" + this.sqlWhere + "','sel_odcutoff:" + this.sel_od_cutoff + "','operate:'" + this.operate + "'";
                this.$pub.printlistbill(this, sql, type, this.styleid, "总汇表", "");
            } else {
                this.$message({
                    type: "info",
                    message: "请先搜索出数据",
                });
            }
        },
        // GetOption() {
        //     this.$tool
        //         .request({
        //             url: "LIS/LIS4/LIS411",
        //             method: "post",
        //             data: {
        //                 action: "get_styleid",
        //             },
        //         })
        //         .then((res) => {
        //             this.styleid = res.styleid; //送达清单样式
        //         })
        //         .catch((e) => {
        //         });
        // },
        cellClickEvent({ row, column }) {
            this.cellreportid = row.reportid;
        },
        //"rm-cancel"; //作废
        //"rm-disable"; //禁用
        //"rm-readonly"; //只读
        //"rm-alert"; //警告
        reportRowName({ row, rowIndex }) {
            if (row.rechk_dt != "" && row.rechk_dt != " " && row.rechk_dt != null) {
                if (XE.toNumber(row.print_count) > 0) {
                    return "rm-gray"; //审核过打印的
                } else {
                    return "colrow"; //没打印的
                }
            }
        },
        reportCellName({ row, rowIndex, column, columnIndex }) {
            if (column.property == "alter_flag") {
                if (row.alter_flag == "1" || row.alter_flag == "2") {
                    return "colred";
                }
            }
            // if (column.property == "emer_flag") {
            //     if (row.emer_flag != "0") {
            //         return "rm_cell_green";
            //     }
            // }
            if (column.property == "redo_flag") {
                if (row.redo_flag == "2" || row.redo_flag == "3") {
                    return "colgreen";
                }
            }
        },
        getButtonWidth() {
            this.buttonWidth = this.$refs.buttondiv.offsetWidth + "px";
        },
        rptunitChange(code, name) {
            this.sel_rptunit = code;
            this.rptunitname = name;
        },
        reqdeptChange(code, name) {
            this.sel_reqdeptno = code;
            this.reqdeptname = name;
        },
        hospChange(code, name) {
            this.sel_hospcode = code;
            this.hospname = name;
        },
        specimenChange(code, name) {
            this.sel_specimencode = code;
            this.specimenname = name;
        },
        reqwardChange(code, name) {
            this.sel_reqwardno = code;
            this.reqwardname = name;
        },
        rptitemChange(code, name) {
            this.sel_rptitemcode = code;
            this.rptitemname = name;
        },
        reqdocChange(code, name) {
            this.sel_reqdocno = code;
            this.reqdocname = name;
        },
        rptunitsChange(code, name) {
            this.sel_rptunitlist = code;
            this.rptunitsname = name;
        },
        btnExportRpt(type) {
            let data = [];
            let filtertxt = "";
            let title = "";
            if (type == 1) {
                data = this.getExportData(1);
                filtertxt = this.getExportFilter();
                title = " report";
            } else if (type == 2) {
                data = this.getExportData(2);
                filtertxt = "条码号:" + this.selrow.barcode + "; 报告ID:" + this.selrow.reportid + "; "
                title = " result";
            }
            this.$pub.exportTableExcelWithData(data, this.exportTableColLen, "LIS411 总汇表" + title + ".xlsx", filtertxt);
        },
        // 获取当前导出文件的所有查询条件
        getExportFilter() {
            let filtertxt = this.datename + ":" + XE.toDateString(this.sample_startdt, "yyyy-MM-dd") + "至" + XE.toDateString(this.sample_enddt, "yyyy-MM-dd") + "; ";
            if (this.sel_rptunit) filtertxt += "报告单元:" + this.rptunitname + "; ";
            if (this.sel_patname) filtertxt += "姓名:" + this.sel_patname + "; ";
            if (this.sel_patname_mh) filtertxt += "姓名模糊查询; ";
            if (this.sel_reqdeptno) filtertxt += "申请科室:" + this.reqdeptname + "; ";
            if (this.sel_hospcode) filtertxt += "所属院区:" + this.hospname + "; ";
            if (this.sel_specimencode) filtertxt += "标本类型:" + this.specimenname + "; ";
            if (this.sel_patno) filtertxt += "病历号:" + this.sel_patno + "; ";
            if (this.sel_patid) filtertxt += "病人ID:" + this.sel_patid + "; ";
            if (this.sel_pattypecode) filtertxt += "病人来源:" + this.getPattypeName() + "; ";
            if (this.sel_reqwardno) filtertxt += "病区:" + this.reqwardname + "; ";
            if (this.sel_sampleno) filtertxt += "标本号:" + this.sel_sampleno + "; ";
            if (this.sel_emerflag) filtertxt += "急诊标志:" + (this.sel_emerflag == "0" ? "常规" : this.sel_emerflag == "1" ? "加急" : "全部") + "; ";
            if (this.sel_barcode) filtertxt += "条码号:" + this.sel_barcode + "; ";
            if (this.sel_reqbedno) filtertxt += "床号:" + this.sel_reqbedno + "; ";
            if (this.sel_rptitemcode) filtertxt += "报告项目:" + this.rptitemname + "; ";
            if (this.sel_reqdocno) filtertxt += "申请医生:" + this.reqdocname + "; ";
            if (this.sel_rflag) filtertxt += "结果标志:" + (this.sel_rflag == "0" ? "异常" : this.sel_rflag == "1" ? "正常" : "全部") + "; ";
            if (this.sel_patdiag) filtertxt += "临床诊断:" + this.sel_patdiag + "; ";
            if (this.sel_rptunitlist) filtertxt += "报告单元多选:" + this.rptunitsname + "; ";
            if (this.sel_rechkflag) filtertxt += "审核状态:" + (this.sel_rechkflag == "0" ? "未审核" : this.sel_rechkflag == "9" ? "已审核" : "全部") + "; ";
            if (this.sel_od_cutoff == "1") filtertxt += "显示OD、SCO、Cutoff值; ";
            return filtertxt;
        },
        getPattypeName() {
            let name = "";
            switch (this.sel_pattypecode) {
                case "1":
                    name = "门诊";
                    break;
                case "2":
                    name = "急诊";
                    break;
                case "3":
                    name = "住院";
                    break;
                case "4":
                    name = "体检";
                    break;
                default:
                    name = "全部";
                    break;
            }
            return name;
        },
        getOptionName(option) {
            if (option && option.length > 0) {
                let optionname = "";
                option.forEach((item) => {
                    if (item.hasOwnProperty("codena")) {
                        optionname += item.codena + ",";
                    } else if (item.hasOwnProperty("display")) {
                        optionname += item.display + ",";
                    } else {
                        optionname += item.label + ",";
                    }
                });
                return optionname.substring(0, optionname.length - 1);
            } else {
                return "";
            }
        },
        getExportData(type) {
            let datas = [];
            if (type == 1) {
                datas = this.$refs.reporttable.afterFullData;
                var allcolumns = this.$refs.reporttable.getColumns();
            } else if (type == 2) {
                datas = this.result_data;
                var allcolumns = this.$refs.resulttable.getColumns();
            }
            var tableColumn = [];
            for (let i = 0; i < allcolumns.length; i++) {
                tableColumn.push({
                    field: allcolumns[i].property,
                    title: allcolumns[i].title,
                });
            }
            this.exportTableColLen = tableColumn.length;
            let columns = tableColumn.filter((item) => item.field);
            let headers = [columns.map((item) => item.title)];
            return headers.concat(
                datas.map((row) => {
                    return columns.map((column) => {
                        return row[column.field];
                    });
                })
            );
        },
    },
};
</script>

<style scoped>
::v-deep .el-checkbox__inner::after {
    border: 2px solid #000000 !important;
    box-sizing: content-box;
    content: "";
    border-left: 0 !important;
    border-top: 0 !important;
    height: 7px;
    left: 4px;
    position: absolute;
    top: 1px;
    transform: rotate(45deg) scaleY(0);
    width: 3px;
    transition: transform 0.15s ease-in 0.05s;
    transform-origin: center;
}

::v-deep .el-checkbox__input.is-disabled+span.el-checkbox__label {
    color: #000000;
    cursor: not-allowed;
}

::v-deep .el-checkbox__input.is-disabled .el-checkbox__inner,
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner+.el-input.is-disabled .el-input__inner {
    background-color: #ffffff !important;
}

::v-deep .el-input--suffix .el-input__inner {
    padding-right: 5px;
}

.middle-tab-bottom {
    position: absolute;
    top: 0px;
    width: 100%;
    bottom: 0px;
    overflow: auto;
}

.pagetop {
    left: 0;
    right: 0;
    height: 215px;
    display: -webkit-box;
    -webkit-box-pack: center;
    -webkit-box-align: center;
    border: solid 1px #ccc;
    position: absolute;
    z-index: 99;
    overflow-x: auto;
    white-space: nowrap;
}

.pagebottom {
    position: absolute;
    width: 100%;
    left: 0;
    margin-top: 4px;
    height: 36px;
    bottom: 0px;
    -webkit-box-pack: center;
    -webkit-box-align: center;
    border: solid 1px #ccc;
}

.middle-right {
    position: absolute;
    top: 0;
    bottom: 0px;
    overflow: visible;
    width: 570px;
    right: 0px;
}

.right-inser {
    position: absolute;
    top: 0;
    bottom: 0px;
    overflow: visible;
    width: 100%;
    right: 0px;
}

table tr td:nth-child(odd) {
    text-align: right;
    white-space: nowrap;
}

table tr td:nth-child(even) {
    text-align: left;
}

table tr td:nth-child(1) {
    width: 80px;
}

table {
    font-size: 12px;
    border-collapse: separate;
    border-spacing: 5px;
}

.avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.avatar-uploader .el-upload:hover {
    border-color: #409eff;
}

.avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
}

.avatar {
    width: 178px;
    height: 178px;
    display: block;
}

.avatar-uploader-icon1 {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 50px;
    line-height: 50px;
    text-align: center;
}

.avatar1 {
    width: 178px;
    height: 50px;
    display: block;
}

.middle-tab-top {
    position: absolute;
    top: 0px;
    width: 100%;
    height: 200px;
}

.middle-bottom {
    position: absolute;
    top: 37px;
    width: 100%;
    bottom: 0px;
    overflow: auto;
}

.middle-tab-bottom {
    position: absolute;
    top: 203px;
    width: 100%;
    bottom: 0px;
    overflow: auto;
}

::v-deep .colred {
    background-color: red !important;
}

::v-deep .colgreen {
    background-color: #00ff00 !important;
}

::v-deep .colrow {
    background-color: #c0ffc0;
}

.fixtotal {
    overflow: hidden;
    position: absolute;
    left: 0px;
    bottom: 3%;
    z-index: 1;
    width: 100%;
}
 .fixtotal2 {
    overflow: hidden;
    position: absolute;
    left: 0px;
    bottom: 10%;
    z-index: 1;
    width: 100%;
}
</style>
